/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */

import java.awt.Graphics2D;
/**
 *
 * @author 86191
 */
public class Triangle extends Shape{
    private double contactRadius;
    private int base;
    private int height;


    
    
    public Triangle(int x, int y, int base, int height) {
        super(x,y);
        this.base = base;
        this.height = height;
        contactRadius = this.contactRadius = Math.sqrt(base * base + height * height) / 2;;
    }
    public int getBase(){return base;}
    public int getHeight(){return height;}
    
    public double getContactRadius() {return contactRadius;}
    public double getMass() {return base * height / 2;}
    
    public void draw(Graphics2D g) {
      
        int left = (int) (getX() - base / 2);
        int top = (int) (getY() - height / 2);
        int[] xPoints = new int[]{left, left + base, left + base / 2};
        int[] yPoints = new int[]{top + height, top + height, top};
        g.fillPolygon(xPoints, yPoints, 3);
    }

}
